﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Marmat.Forms.Skin
{
    public class DirectUIPanel : System.Windows.Forms.UserControl
    {

        private readonly DirectUIContainer directUIContainer;

        public DirectUIPanel()
        {
            this.directUIContainer = new DirectUIContainer();
            this.directUIContainer.Dock = DockStyle.Fill;
            this.directUIContainer.Bind(this);
            this.directUIContainer.BackColor = Color.Red;

            var item = new DirectUIControl() { Name = "1", BackColor = Color.Green, Location = new System.Drawing.Point(20, 20), Size = new System.Drawing.Size(40, 40) };
            item.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            this.directUIContainer.Controls.Add(item);

            //var container = new DirectUIContainer() { Name = "3", BackColor = Color.Orange, Location = new System.Drawing.Point(100, 100), Size = new System.Drawing.Size(200, 200) };
            //container.Controls.Add(new DirectUIControl() { Name = "31", BackColor = Color.Green, Location = new System.Drawing.Point(10, 10), Size = new System.Drawing.Size(40, 40) });
            //item = container;
            //this.directUIContainer.Controls.Add(item);
        }

        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
            directUIContainer.OnMouseClick(e);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            directUIContainer.Draw(e);
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            Console.WriteLine(DateTime.Now);
        }
    }
}
